package com.huqing.icu.controller.admin;

import com.huqing.icu.base.BaseController;
import com.huqing.icu.base.IdReq;
import com.huqing.icu.inout.in.admin.AdminHouseListQueryReq;
import com.huqing.icu.inout.in.admin.HouseApproveReq;
import com.huqing.icu.service.admin.IAdminHouseService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description 后台房源接口
 * @Author huqing
 * @Date 2025/9/13 23:50
 **/
@RestController
@RequestMapping("/admin/house")
@Tag(name = "后台房源接口")
public class AdminHouseController extends BaseController {

    @Autowired
    private IAdminHouseService iAdminHouseService;

    @Operation(summary = "查看房源列表")
    @RequestMapping(value = "/query_list", method = RequestMethod.POST, produces = "application/json")
    public String queryList(HttpServletRequest request, @RequestBody AdminHouseListQueryReq queryReq) {
        Long userId = getLoginUserId(request);
        return jsonSuccessForNull(iAdminHouseService.queryList(queryReq));
    }

    @Operation(summary = "查看房源详情")
    @RequestMapping(value = "/query_detail", method = RequestMethod.POST, produces = "application/json")
    public String queryDetail(HttpServletRequest request, @RequestBody IdReq idReq) {
        Long userId = getLoginUserId(request);
        return jsonSuccessForNull(iAdminHouseService.queryDetail(idReq.getId()));
    }

    @Operation(summary = "审核房源")
    @RequestMapping(value = "/approve", method = RequestMethod.POST, produces = "application/json")
    public String approve(HttpServletRequest request, @RequestBody HouseApproveReq approveReq) {
        Long userId = getLoginUserId(request);
        approveReq.setApproveUserId(userId);
        return jsonSuccessForNull(iAdminHouseService.approve(approveReq));
    }
}
